import React from 'react';
import {View,Image} from '@tarojs/components';
import Taro from '@tarojs/taro';
import './index.scss';
import uploadfile from '../../static/images/uploadfile.png';
import indexBottomBanner from '../../static/images/indexBottomBanner.jpg';
import indexTopBanner from '../../static/images/indexTopBanner.jpg';
import buttonIcon from '../../static/images/buttonIcon.png';

// import './CommodList.scss';
// interface IProps{
//
// }
 const Index:React.FC = () =>{
  //上传搜索图片
  const searchImages = ():void => {
    Taro.chooseImage({
      success:(res)=>{
        const tempFilePaths = res.tempFilePaths;
        Taro.uploadFile({
          url:'http://47.96.146.127/api/upload',
          filePath:tempFilePaths[0],
          name:'file',
          success:(upImgRes) =>  {
            console.log(upImgRes);
            Taro.navigateTo({
              url:'/pages/CommodList/CommodList'
            })
          }
        })
      }
    })
  }

  return (
    <View className='index' >
        <View className='indexTop model'>
          <Image src={indexTopBanner} className='backGround' mode='widthFix'></Image>
          <View className='radiusMot' onClick={searchImages}>
            <Image src={uploadfile} className='upLoadFileIcon'></Image>
          </View>
          <View className='searchTextTop searchText'>点击选择图片搜索</View>
        </View>
        <View className='indexBottom model'>
          <Image src={indexBottomBanner} className='backGround' mode='widthFix'></Image>
          <View className='radiusMot animate' onClick={searchImages}>
            <Image src={buttonIcon} style='width:100%;height:100%' className='upLoadFileIcon'></Image>
          </View>
          <View className='searchTextBottom searchText'>点击选择图片搜索</View>
        </View>
    </View>
  )
}

export default Index;

